package com.eudon.ai.agent.common;

import cn.hutool.core.util.HashUtil;
import org.springframework.ai.document.id.IdGenerator;

import java.util.Arrays;
import java.util.stream.Collectors;

/**
 * @author eudon
 * @description 自定义ID generator
 * @date 2025/8/20
 * @email syd19970616@gmail.com
 * @address <a href="https://gitee.com/eudon">Gitee</a>
 */
public class MyIdGenerator implements IdGenerator {
    @Override
    public String generateId(Object... contents) {
        String mixStr = Arrays.stream(contents)
                .map(Object::toString)
                .collect(Collectors.joining(","));
        long hash = HashUtil.mixHash(mixStr);
        return String.valueOf(hash);
    }
}
